package com.mc.linkerlist;

public class MainTest {
    public static void main(String[] args) {
        dLinkList();
    }

    static void linkList(){
        // 声明一个指向单链表的指针
        HLinkerList L = new HLinkerList();
        int num = 2;

        L.InitList(L);
        L.head.next = new HNode(1);
        L.head.next.next = new HNode(2);
        L.head.next.next.next = new HNode(3);
        HNode node = L.GetElem(L, num);

        L.ListInsert(L, 2, 4);
        L.InsertNextNode(node, 5);
        L.InsertPriorNode(node, 6);
        L.DeleteNode(node);

        System.out.println("获取第" + num + "个元素:" + L.LocateElem(L, 2).data);
        System.out.println("获取第" + num + "个元素:" + L.GetElem(L, num - 1).data);
        System.out.println("表长:" + L.Length(L));

        L.Length(L);
    }

    static void dLinkList(){
        // 声明一个指向单链表的指针
        HDLinkedList L = new HDLinkedList();
        int num = 2;

        L.InitList(L);
        L.head.next = new HDNode(1);
        L.head.next.next = new HDNode(2);
        L.head.next.next.next = new HDNode(3);

        L.InsertNextHDNode(L.head.next.next, new HDNode(5));
        L.DeleteNextNode(L.head.next.next);

        System.out.println(L.Length(L));
    }
}
